<!DOCTYPE html>
<html>
<head>
	<title></title>
</head>
<body>

<script type="text/javascript">
	
let model = {};
model.test1 = 1;
model.test2 = 2;
model.test3 = {};

var constantize = (obj) => {
	Object.freeze(obj);
	Object.keys(obj).forEach( (key, value) => {
		if ( typeof obj[key] === 'object' ) {
			constantize( obj[key] );
		}
	});
};

constantize(model);
const foo = model;

console.error(foo.test1);
console.error(foo.test2);
console.error(foo.test3);

foo.test3.test4 = 4;
console.error(foo.test3);
console.error(foo.test3.test4);

//递归冻结对象属性

</script>

</body>
</html>